//
//  JDImageCollectionViewCell.swift
//  DragonWallet
//
//  Created by volantPig on 2025/3/17.
//

import UIKit

class JDImageCollectionViewCell: UICollectionViewCell {
    
    lazy var mainImageView: UIImageView = {
        let imageV = UIImageView()
        return imageV
    }()
    
    lazy var playImageV: UIImageView = {
        let imageV = UIImageView()
        imageV.image = UIImage(named: "play_button")?.withRenderingMode(.alwaysOriginal)
        imageV.isHidden = true
        return imageV
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.setupUIElements()
    }
    
    func setupUIElements() {
        
        self.contentView.addSubview(mainImageView)
        mainImageView.snp.makeConstraints { make in
            make.leading.trailing.top.bottom.equalToSuperview()
        }
        
//        let videoUrl = self.recruitModel?.videoUrl ?? ""
//        let url = self.collectionViewDataSource[indexPath.row]
//        if url == videoUrl {
//            // 视频
//            imageV.image = JDTools.getVideoThumbnail(url: URL(string: url)!)
//        } else {
//            // 图片
//            if url.hasPrefix("http") {
//                imageV.kf.setImage(with: URL(string: url))
//            } else {
//                imageV.downloadImage(url)
//            }
//        }
        
        self.mainImageView.addSubview(self.playImageV)
        self.playImageV.snp.makeConstraints { make in
//            make.leading.trailing.top.bottom.equalTo(self.mainImageView)
            make.center.equalTo(self.mainImageView)
        }
    }
    
    func isVideo() {
        self.playImageV.isHidden = false
    }
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
